import http from '@/api'
import { ADMIN_MODULE } from '@/api/helper/prefix'
import type { IPage } from '@/api/interface'
import type { ISysPost } from '@/api/interface/system/sysPost'

/**
* 查询列表
* @param params
* @returns {*}
*/
export const getSysPostListApi = (params: ISysPost.Query) => {
  return http.get<IPage<ISysPost.Row>>(ADMIN_MODULE + `/sys-post/list`, params)
}

export const getSysPostOptionApi = () => {
  return http.get<ISysPost.Row[]>(ADMIN_MODULE + `/sys-post/option`)
}

/**
* 添加
* @param params
* @returns {*}
*/
export const addSysPostApi = (params: ISysPost.Form) => {
  return http.post(ADMIN_MODULE + `/sys-post/add`, params)
}

/**
* 修改
* @param params
* @returns {*}
*/
export const updateSysPostApi = (params: ISysPost.Form) => {
  return http.post(ADMIN_MODULE + `/sys-post/update`, params)
}

/**
* 删除
* @param params
* @returns {*}
*/
export const removeSysPostApi = (params: { ids: number[] }) => {
  return http.post(ADMIN_MODULE + `/sys-post/remove`, params)
}

/**
* 获取详情
* @param params
* @returns {*}
*/
export const getSysPostDetailApi = (params: { id: number }) => {
  const { id } = params
  return http.get<ISysPost.Row>(ADMIN_MODULE + `/sys-post/${id}`)
}

